package edu.whut.jdk8.localClass;
/*
ZoneTd：时区类
常用方法：
1.static Set<String> getAvailableZoneIds() :获取java中支持的所以时区
2.static ZoneId systemDefault():获取系统默认时区
3.static ZoneId of(String zoneId):获取一个指定的时区
 */
import com.sun.corba.se.impl.orbutil.CorbaResourceUtil;

import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.Set;

public class ZoneDemo {
    public static void main(String[] args) {
        //Instant时间戳
        Instant now = Instant.now();
        System.out.println(now);
        ZonedDateTime zonedDateTime = Instant.now().atZone(ZoneId.of("Asia/Shanghai"));
        System.out.println(zonedDateTime);
        System.out.println("-----------------------");

        //java中支持的所有时区
        Set<String> set = ZoneId.getAvailableZoneIds();
        System.out.println(set);
        System.out.println(set.size());
        System.out.println("-----------------------");

        //获取默认时区
        ZoneId zoneId = ZoneId.systemDefault();
        System.out.println(zoneId);
        System.out.println("-----------------------");

        //获取指定时区的时间
        ZoneId of = ZoneId.of("America/El_Salvador");
        System.out.println(of);
        ZonedDateTime zonedDateTime1 = Instant.now().atZone(of);
        System.out.println(zonedDateTime1);

    }
}
